//
//  MyBidJobDetailTabDetailSectionPublishDetail.swift
//  GreenDeal
//
//  Created by Moennig Q on 2023/4/18.
//

import UIKit
import SnapKit
class ServiceDetailTabDetailSectionPublishDetail: CustomBackView {
    let publisherLabel = ContentLabel(R.font.interBold(size: 14))
    let publisherPhoneLabel = ContentLabel(R.font.interMedium(size: 13),hexStr: "#292D32B2")
    let publisherEmailLabel = ContentLabel(R.font.interMedium(size: 13),hexStr: "#292D32B2")
    let companyLabel = ContentLabel(R.font.interMedium(size: 13),hexStr: "#292D32B2")
    let dateLabel = ContentLabel(R.font.interMedium(size: 13),hexStr: "#292D32B2")
    let callPhoneBtn = UIButton()
    override func setUpView() {
        //publisher
        self.addSubview(publisherLabel)
        publisherLabel.snp.makeConstraints { (make) in
            make.left.top.equalTo(16)
            make.height.width.greaterThanOrEqualTo(20)
        }
        //phone
        let phoneImageView = UIImageView(image: UIImage(named: "service_myjob_detail_phone_icon"))
        self.addSubview(phoneImageView)
        phoneImageView.snp.makeConstraints { (make) in
            make.top.equalTo(publisherLabel.snp.bottom).offset(12)
            make.left.equalTo(publisherLabel)
            make.height.width.equalTo(16)
        }
        //
        self.addSubview(publisherPhoneLabel)
        publisherPhoneLabel.snp.makeConstraints { (make) in
            make.left.equalTo(phoneImageView.snp.right).offset(8)
            make.height.width.greaterThanOrEqualTo(0)
            make.centerY.equalTo(phoneImageView)
        }
        //email
        let emailImageView = UIImageView(image: UIImage(named: "service_myjob_detail_email_icon"))
        self.addSubview(emailImageView)
        emailImageView.snp.makeConstraints { (make) in
            make.top.equalTo(phoneImageView.snp.bottom).offset(8)
            make.left.equalTo(publisherLabel)
            make.size.equalTo(phoneImageView)
        }
        //
        self.addSubview(publisherEmailLabel)
        publisherEmailLabel.snp.makeConstraints { (make) in
            make.left.equalTo(publisherPhoneLabel)
            make.height.width.greaterThanOrEqualTo(0)
            make.centerY.equalTo(emailImageView)
        }
        //company
        let companyImagView = UIImageView(image: UIImage(named: "service_bidjob_detail_company_icon"))
        self.addSubview(companyImagView)
        companyImagView.snp.makeConstraints { (make) in
            make.top.equalTo(emailImageView.snp.bottom).offset(8)
            make.left.equalTo(publisherLabel)
            make.size.equalTo(phoneImageView)
        }
        //3.1.2
        self.addSubview(companyLabel)
        companyLabel.snp.makeConstraints { (make) in
            make.left.equalTo(publisherPhoneLabel)
            make.height.width.greaterThanOrEqualTo(0)
            make.centerY.equalTo(companyImagView)
        }
        //3.1.3
        let timeImageView = UIImageView(image: UIImage(named: "service_bidjob_detail_time_icon"))
        self.addSubview(timeImageView)
        timeImageView.snp.makeConstraints { (make) in
            make.top.equalTo(companyImagView.snp.bottom).offset(8)
            make.left.equalTo(publisherLabel)
            make.size.equalTo(phoneImageView)
        }
        //3.1.3
        self.addSubview(dateLabel)
        dateLabel.snp.makeConstraints { (make) in
            make.left.equalTo(publisherPhoneLabel)
            make.height.width.greaterThanOrEqualTo(0)
            make.centerY.equalTo(timeImageView)
            make.bottom.equalTo(-16)
        }
        //1.1.6.3 call phone button
        self.addSubview(callPhoneBtn)
        callPhoneBtn.snp.makeConstraints { (make) in
            make.right.equalTo(-16)
            make.bottom.equalTo(emailImageView)
            make.height.width.equalTo(40)
        }
        callPhoneBtn.setImage(UIImage(named: "service_myjob_detail_callphone_icon"), for: UIControl.State.normal)
    }
    func setData(_ model: ServiceDetailModel){
        //publisher detail
        companyLabel.text = model.company
        publisherLabel.text = model.publisher
        publisherEmailLabel.text = model.publisher_email
        publisherPhoneLabel.text = model.publisher_phone
        dateLabel.text = model.created_at
        
    }
}
